/**
 *  const [types, typeEnum] = createEnum([{ name: "一月", value: 0, enum: "JAN"}]);
 *
 *  types 就是 [{ name: "一月", value: 0}]
 *
 *  typeEnum 就是 { JAN: 0 }
 */
export default function createEnum(values) {
  const array = [];
  const enumObj = {};
  for (const v of values) {
    const obj = {
      name: v.name,
      value: v.value
    };
    Object.freeze(obj);
    array.push(obj);

    if (v.enum) {
      enumObj[v.enum] = v.value;
    }
  }
  Object.freeze(array);
  Object.freeze(enumObj);

  return [array, enumObj];
}
